﻿using IntelligentAgriculture.Contracts.Interface.EarTagService;
using IntelligentAgriculture.Contracts.Interface.IManagements;
using IntelligentAgriculture.Services.Management;
using IntelligentAgriculture.WebAPI.Application.Command.EarTageCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.ColumnManageCommandJamdler
{
    public class EarTageDelCommandHandler : IRequestHandler<EarTageDelCommand, Results<int>>
    {
        private readonly IEarTageService _iearTageService;

        public EarTageDelCommandHandler(IEarTageService iearTageService)
        {
            _iearTageService = iearTageService;
        }
        /// <summary>
        /// 删除耳标命令的请求
        /// </summary>
        /// <param name="request">要处理的耳标删除命令</param>
        /// <param name="cancellationToken">取消操作的取消标记</param>
        /// <returns>一个表示操作结果的异步任务，返回删除操作的结果</returns>
        public async Task<Results<int>> Handle(EarTageDelCommand request, CancellationToken cancellationToken)
        {
            var list = await _iearTageService.Delete(request.Id);
            return Results<int>.DataResult(list);
        }
    }
}
